package collection;

import java.util.ArrayList;
import java.util.List;

public class ListDemo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println(list);
       // [one, two, three, four, five]
        /**
         * void add (int index,E e)
         * 将给定元素插入到指定位置
         * */
        list.add(2,"six");
        System.out.println(list);//[one, two, six, three, four, five]
        String e =list.remove(4);
        System.out.println(list);//[one, two, six, three, five]
        System.out.println("被删除的元素是"+e);//被删除的元素是four


    }
}
